﻿<!doctype html>
<html lang="en">
<head>
    <script type="text/javascript" src="js/jquery-2.1.3.js"></script>
    <script type="text/javascript" src="js/highstock.js"></script>
    <script type="text/javascript" src="js/modules/exporting.js"></script>
    <script>
        $(function () {

            // http://localhost/rest/rest/analyze?end=20150304&level=1&start=20140901
            var u = decodeURIComponent(window.location.href);
            var par = u.substring(u.lastIndexOf('?') + 1, u.length);
            var d = par.split('&');
            var end_date = "", level = "1", start_date = "",type="";
            for (var i = 0; i < d.length; i++) {
                var keyValue = d[i].split('=');
                var key = keyValue[0];
                var value = keyValue[1];
                if (key == "start") start_date = value;
                if (key == "end") end_date = value;
                if (key == "level") level = value;
                if (key == "type") type = value;
                //alert('the key is:' + key);
                //alert('the value is:' + value);
            }

            var url = "/rest/rest/statistics?start=" + start_date + "&level=" + level + "&end=" + end_date+"&type="+type;

            var t = $.getJSON(url, function (data) {
                for (var i in data) {
                    var newRow = "<tr>";
                    var big = data[i]["big"];
                    var sid = data[i]["sid"];
                    var link = "<a target='_parent' href='/web/single_dynamic.html?sid=" + sid + "&big=" + big + "'>" + sid + "</a>";
                    newRow += "<td>" + link + "</td>";
                    newRow += "<td>" + data[i]["name"] + "</td>";

                    var ind1 = data[i]["firstlevel"];
                    var ind2 = data[i]["secondlevel"];

                    var ind_link1 = "<a target='_parent' href='/web/company.html?industry1=" + ind1 + "'>" + ind1 + "</a>";
                    newRow += "<td>" + ind_link1 + "</td>";
                    var ind_link2 = "<a target='_parent' href='/web/company.html?industry1=" + ind1 + "&industry2=" + ind2 + "'>" + ind2 + "</a>";
                    newRow += "<td>" + ind_link2 + "</td>";

                    var lastupdate = data[i]["lastupdate"];
                    var startdate = data[i]["startdate"];

                    //newRow += "<td>" + start_date + "</td>";
                    //newRow += "<td>" + end_date + "</td>";
                    newRow += "<td>" + data[i]["rank"]; + "</td>";
                    newRow += "<td>" + data[i]["value"]; + "</td>";
                    $("#table1 tr:last").after(newRow);
                }
            });
        });

    </script>
</head>
<body>
    <div id="input">
        <table id="table1" border="1"><tr><th>id</th><th>name</th><th>industry1</th><th>industry2</th><!--<th>startdate</th><th>lastupdate</th>--><th>rank</th><th>value</th></tr></table>
    </div>

    <a id="industry1" href=""></a>
    
</body>
</html>